<script setup lang="ts">
import { useRouter } from 'vue-router'
import { ref, onMounted } from 'vue'

const router = useRouter()
const showAnimation = ref(false)

const navigateTo = (path: string) => {
  router.push(path)
}

onMounted(() => {
  setTimeout(() => {
    showAnimation.value = true
  }, 300)
})
</script>

<template>
  <div class="home-container">
    <!-- 背景元素 -->
    <div class="tech-background"></div>
    <div class="grid-overlay"></div>
    <div class="particles">
      <div v-for="n in 20" :key="n" class="particle"></div>
    </div>
    
    <!-- 主要内容 -->
    <div class="content" :class="{ 'show-animation': showAnimation }">
      <div class="title-container">
        <h1 class="glitch-title" data-text="TAO AI 智能助手">TAO AI <span class="highlight">智能助手</span></h1>
        <p class="subtitle">探索AI的无限可能</p>
      </div>
      
      <div class="app-selection">
        <div class="app-card" @click="navigateTo('/love-master')">
          <div class="app-icon">❤️</div>
          <div class="card-content">
            <h2>AI 恋爱大师</h2>
            <p>与AI恋爱大师聊天，获取恋爱建议和情感支持</p>
          </div>
          <div class="card-overlay"></div>
          <div class="card-glow"></div>
        </div>
        
        <div class="app-card" @click="navigateTo('/super-agent')">
          <div class="app-icon">🤖</div>
          <div class="card-content">
            <h2>AI 超级智能体</h2>
            <p>体验强大的AI助手，解决各种问题和挑战</p>
          </div>
          <div class="card-overlay"></div>
          <div class="card-glow"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0f1923 0%, #1a1f35 100%);
  color: var(--text-light);
}

/* 背景效果 */
.tech-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(66, 184, 131, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(66, 184, 131, 0.15) 0%, transparent 50%);
  z-index: 1;
  opacity: 0.8;
}

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(66, 184, 131, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 184, 131, 0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  z-index: 2;
}

.particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background-color: rgba(66, 184, 131, 0.6);
  border-radius: 50%;
  animation: float 15s infinite linear;
}

.particle:nth-child(odd) {
  width: 2px;
  height: 2px;
  background-color: rgba(255, 255, 255, 0.4);
}

.particle:nth-child(3n) {
  width: 4px;
  height: 4px;
  background-color: rgba(66, 184, 131, 0.8);
  animation-duration: 20s;
}

.particle:nth-child(5n) {
  width: 1px;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.3);
  animation-duration: 25s;
}

@keyframes float {
  0% {
    transform: translate(0, 0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--move-x, 100px), var(--move-y, 100px));
    opacity: 0;
  }
}

/* 主要内容样式 */
.content {
  position: relative;
  z-index: 10;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.content.show-animation {
  opacity: 1;
  transform: translateY(0);
}

.title-container {
  margin-bottom: 3rem;
  text-align: center;
}

.glitch-title {
  color: white;
  font-size: 3.5rem;
  font-weight: 800;
  text-shadow: 0 0 15px rgba(66, 184, 131, 0.7);
  letter-spacing: 2px;
  position: relative;
  animation: glitch 5s infinite;
}

.glitch-title::before,
.glitch-title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.8;
}

.glitch-title::before {
  color: #0ff;
  z-index: -1;
  animation: glitch-animation 5s infinite;
}

.glitch-title::after {
  color: #f0f;
  z-index: -2;
  animation: glitch-animation-2 5s infinite;
}

@keyframes glitch-animation {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 3px); }
  40% { transform: translate(-3px, -3px); }
  60% { transform: translate(3px, 3px); }
  80% { transform: translate(3px, -3px); }
}

@keyframes glitch-animation-2 {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(3px, -3px); }
  40% { transform: translate(3px, 3px); }
  60% { transform: translate(-3px, -3px); }
  80% { transform: translate(-3px, 3px); }
}

.subtitle {
  color: var(--text-light);
  font-size: 1.2rem;
  margin-top: 0.5rem;
  opacity: 0.8;
  letter-spacing: 1px;
}

.highlight {
  color: var(--primary-color);
  position: relative;
}

.highlight::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

/* 应用卡片样式 */
.app-selection {
  display: flex;
  gap: 2.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.app-card {
  width: 280px;
  height: 320px;
  background: rgba(28, 39, 60, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 1.8rem;
  cursor: pointer;
  transition: all 0.4s ease;
  text-align: center;
  border: 1px solid rgba(66, 184, 131, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.app-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: rgba(66, 184, 131, 0.6);
}

.app-card:hover .card-glow {
  opacity: 1;
}

.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(66, 184, 131, 0.1) 0%, rgba(28, 39, 60, 0) 100%);
  z-index: 1;
}

.card-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(66, 184, 131, 0.4) 0%, rgba(66, 184, 131, 0) 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 0;
  pointer-events: none;
}

.card-content {
  position: relative;
  z-index: 2;
}

.app-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.7));
  position: relative;
  z-index: 2;
}

.app-card h2 {
  margin-bottom: 1rem;
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 700;
  position: relative;
  z-index: 2;
}

.app-card p {
  color: #b8c2cc;
  line-height: 1.6;
  font-size: 1rem;
  position: relative;
  z-index: 2;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-selection {
    flex-direction: column;
    align-items: center;
    gap: 2rem;
  }
  
  .glitch-title {
    font-size: 2.5rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .app-card {
    width: 260px;
    height: 300px;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 1.5rem;
  }
  
  .glitch-title {
    font-size: 2rem;
  }
  
  .app-card {
    width: 240px;
    height: 280px;
    padding: 1.5rem;
  }
  
  .app-icon {
    font-size: 3.5rem;
    margin-bottom: 1.2rem;
  }
}
</style>